package com.lt.report.service.Impl;

import com.lt.contract.bean.NMContractNew;
import com.lt.contract.bean.NM_CONTRACT_2019;
import com.lt.contract.dao.*;
import com.lt.contract.entity.*;
import com.lt.contract.service.NmOneStopServiceService;
import com.lt.hr.dao.THrEmpInfoDao;
import com.lt.hr.entity.THrEmpInfo;
import com.lt.report.bean.ItemExpend;
import com.lt.report.dao.ItemExpendMapper;
import com.lt.report.service.AsyncService;
import com.lt.report.service.ImportServiceInterFace;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.List;

@Service
@Slf4j
public class AsyncServiceImpl implements AsyncService {

    @Resource
    ItemExpendMapper itemExpendMapper;

    @Resource
    NM_CONTRACT_2019Mapper nmContract2019Mapper;

    @Resource
    NmMongoliaCircuitSharingDao mongoliaCircuitSharingDao;
    @Resource
    InnovativeBusinessDao innovativeBusinessDao;

    @Resource
    NmMobileServiceDao nmMobileServiceDao;

    @Resource
    NmInternetOfThingsDao nmInternetOfThingsDao;

    @Resource
    NmCirciuitRealationDao nmCirciuitRealationDao;

    @Resource
    THrEmpInfoDao tHrEmpInfoDao;

    @Resource
    NmOneStopServiceDao nmOneStopService;

    @Resource
    NmBoutiqueNetworkDao nmBoutiqueNetworkDao;

    @Resource
    NMContractNewMapper nmContractNewMapper;


    @Async("asyncServiceExecutor")
    public void executeAsync(List<ItemExpend> lists) {
        log.info("start executeAsync");
        try {
            itemExpendMapper.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end executeAsync");
    }

    @Async("asyncServiceExecutor")
    public void executeContract2019(List<NM_CONTRACT_2019> lists) {
        log.info("start executeAsync");
        try {
            nmContract2019Mapper.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end executeAsync");
    }

    @Override
    public void executeNmMSharing(List<NmMongoliaCircuitSharing> lists) {
        log.info("start mongoliaCircuitSharingDao upload");
        try {
            mongoliaCircuitSharingDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end mongoliaCircuitSharingDao upload");
    }

    @Override
    public void executeInnovative(List<InnovativeBusiness> lists) {
        log.info("start InnovativeBusiness upload");
        try {
            innovativeBusinessDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end InnovativeBusiness upload");
    }

    @Override
    public void executeMobile(List<NmMobileService> lists) {
        log.info("start mobileService upload");
        try {
            nmMobileServiceDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end mobileService upload");
    }

    @Override
    public void executeInternetOfThings(List<NmInternetOfThings> lists) {
        log.info("start InternetOfThings upload");
        try {
            nmInternetOfThingsDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end InternetOfThings upload");
    }

    @Override
    public void executeCirciuitRealation(List<NmCirciuitRealation> lists) {
        log.info("start nmCirciuitRealationDao upload");
        try {
            nmCirciuitRealationDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end nmCirciuitRealationDao upload");
    }

    @Override
    public void executeTHrEmpInfo(List<THrEmpInfo> lists) {
        log.info("start tHrEmpInfoDao upload");
        try {
            tHrEmpInfoDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end tHrEmpInfoDao upload");
    }

    @Override
    public void executeOneStep(List<NmOneStopService> lists) {
        log.info("start nmOneStopService upload");
        try {
            nmOneStopService.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end nmOneStopService upload");
    }

    @Override
    public void executeBoutigue(List<NmBoutiqueNetwork> lists) {
        log.info("start NmBoutiqueNetwork upload");
        try {
            nmBoutiqueNetworkDao.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end NmBoutiqueNetwork upload");
    }

    @Override
    public void executeContractRealationSerial(List<NMContractNew> lists) {
        log.info("start executeContractRealationSerial upload");
        try {
            nmContractNewMapper.insertAll(lists);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("end executeContractRealationSerial upload");
    }

}
